#include "GUILabel.h"
#include "IRenderer.h"
#include "Matrix.h"
#include "OnKeyPressEvent.h"
#include "OnMouseLeftDownEvent.h"
#include "GUIWindow.h"

GUILabel::GUILabel()
{
	m_fontColor = 0x00000000;
	m_font = HashedString("Arial");
	m_visible = true;
	m_enabled = true;
	m_dimensions = Maths::Point<unsigned int>(1, 1);
}

bool GUILabel::ReceiveEvent( IEvent& event )
{
	return false;
}

void GUILabel::Paint()
{
	if (m_visible)
	{
		// Render background
		Maths::Matrix transform;
		transform.Translate(m_location.X, m_location.Y, 0.0f);
		transform.Scale(m_dimensions.X, m_dimensions.Y, 1.0f);

		Renderer->SetColor(0xFFDDDDDD);
		Renderer->PushTexture(m_background);
		Renderer->PushModelViewMatrix(transform);
		Renderer->Render(*(m_shape.getShape()));
		Renderer->PopModelViewMatrix();
		Renderer->PopTexture();
		Renderer->SetColor(0xFFFFFFFF);

		// Render text
		Renderer->PrintFont(m_font, m_fontColor, m_parentLocation.X + m_location.X+4, m_parentLocation.Y + m_location.Y+4, m_text.c_str());
	}
}
void GUILabel::Text( std::string& title )
{
	m_text = title;
}

std::string GUILabel::Text() const
{
	return m_text;
}

void GUILabel::Font( std::string& font )
{
	m_font = HashedString(font);
}

void GUILabel::Font( HashedString& font )
{
	m_font = font;
}

HashedString GUILabel::Font() const
{
	return m_font;
}

void GUILabel::FontColor( unsigned int color )
{
	m_fontColor = color;
}

unsigned int GUILabel::FontColor() const
{
	return m_fontColor;
}

void GUILabel::Background( std::string& background )
{
	m_background = HashedString(background);
}

void GUILabel::Background( HashedString& background )
{
	m_background = background;
}

HashedString GUILabel::Background() const
{
	return m_background;
}